package com.game.majiang.vo;

import java.sql.Types;
import java.util.ArrayList;

import javax.sql.rowset.CachedRowSet;

import com.game.majiang.algorithm.entity.GameTask;
import com.game.server.db.Parameter;
import com.game.server.db.ParameterType;
import com.game.server.db.SqlHelperwrite;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class UserDatasVo {

	
	
	
	public static String listWarpAndWeftsToString(ArrayList<String> list) {
		StringBuffer str = new StringBuffer();
		for (String string : list) {
			str.append(string+",");
		}
		String s = str.toString();
		if (s.length() > 2) {
			s = s.substring(0, s.length()-1);
		}		 
		return s;
	}
	
	public static String listGameTaskToJson(ArrayList<GameTask> list) {
		JSONArray json = new JSONArray();
		for (GameTask gt : list) {
			JSONObject js1 = new JSONObject();
			js1.put("count", gt.count);
			js1.put("id", gt.id);
			js1.put("starttime", gt.starttime);
			js1.put("receive", gt.receive);
			json.add(js1);
		}
		return json.toString();
	}
	
	public static ArrayList< GameTask> listJsonToGameTask(String jsonstr) {
		ArrayList< GameTask> listGameTask = new ArrayList<>();
		JSONArray json = JSONArray.fromObject(jsonstr);
		for (Object object : json) {
			JSONObject js1 = JSONObject.fromObject(object);
			GameTask gt = new GameTask();
			gt.count = js1.getLong("count");
			gt.id = js1.getInt("id");
			gt.starttime = js1.getLong("starttime");
			gt.receive = js1.getInt("receive");
			listGameTask.add(gt);
		}
		
		return listGameTask;
	}
	
}


